import java.util.*;
//public class Main {
//    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//        int[] arr = new int[n];
//        for (int i = 0; i < n; i++) {
//            arr[i] = sc.nextInt();
//        }
//        // Java的数组去重方法
//        Arrays.sort(arr);
//        int[] res = Arrays.stream(arr).distinct().toArray();
//        System.out.println(Arrays.toString(res));
//    }
//}

import java.util.*;
import java.util.stream.Collectors;

import javafx.util.Pair;

public class Main {
    static int n,m;
    final static int N = 300005;
    static int[] a = new int[N];
    static int[] s = new int[N];
    static ArrayList<Integer> alls = new ArrayList<Integer>();
    static ArrayList<Pair<Integer,Integer>> add = new ArrayList<Pair<Integer,Integer>>();
    static ArrayList<Pair<Integer,Integer>> query = new ArrayList<Pair<Integer,Integer>>();
    static int find(int x)
    {
        int l = 0,r = alls.size() - 1;
        while(l < r)
        {
            int mid = (l + r)/2;
            if(alls.get(mid)>=x)r = mid;
            else l = mid + 1;
        }
        return r + 1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt() , c = sc.nextInt();
            Pair<Integer,Integer> pair = new Pair<>(x,c);
            add.add(pair);
            alls.add(x);
        }


        for(int i = 0 ; i < m; i++)
        {
            int l = sc.nextInt() , r = sc.nextInt();
            Pair<Integer,Integer> pair = new Pair<>(l,r);
            query.add(pair);
            alls.add(l);
            alls.add(r);
        }

        Collections.sort(alls);
        List<Integer> newlist = alls.stream().distinct().collect(Collectors.toList());
        alls.clear();
        alls.addAll(newlist);




    }
}

















